<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>super用法</title>
    <script>
        class Animal{
            constructor(name){
                this.name=name
            }

            sayhello(){
                console.log("动物在叫~")
            }
        }

        class cat extends Animal{
            constructor(name,age){
                //调用父类构造函数
                super(name)
                this.age=age
            }

            sayhello(){
                //用super可调用父类方法
                super.sayhello()
                console.log("喵喵~")
            }
        }

        const animal1 = new Animal("animal");
        const cat1 = new cat("Amy",2);
        animal1.sayhello();
        cat1.sayhello();
    </script>
</head>
<body>
    
</body>
</html>